import 'package:gameplay_flutter/generated/json/base/json_convert_content.dart';
import 'package:gameplay_flutter/lib_basemodel/discover/address_info_entity.dart';

AddressInfoEntity $AddressInfoEntityFromJson(Map<String, dynamic> json) {
  final AddressInfoEntity addressInfoEntity = AddressInfoEntity();
  final AddressInfoPlusCode? plusCode = jsonConvert.convert<AddressInfoPlusCode>(json['plus_code']);
  if (plusCode != null) {
    addressInfoEntity.plusCode = plusCode;
  }
  final List<AddressInfoResults>? results = (json['results'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<AddressInfoResults>(e) as AddressInfoResults).toList();
  if (results != null) {
    addressInfoEntity.results = results;
  }
  final String? status = jsonConvert.convert<String>(json['status']);
  if (status != null) {
    addressInfoEntity.status = status;
  }
  return addressInfoEntity;
}

Map<String, dynamic> $AddressInfoEntityToJson(AddressInfoEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['plus_code'] = entity.plusCode.toJson();
  data['results'] = entity.results.map((v) => v.toJson()).toList();
  data['status'] = entity.status;
  return data;
}

extension AddressInfoEntityExtension on AddressInfoEntity {
  AddressInfoEntity copyWith({
    AddressInfoPlusCode? plusCode,
    List<AddressInfoResults>? results,
    String? status,
  }) {
    return AddressInfoEntity()
      ..plusCode = plusCode ?? this.plusCode
      ..results = results ?? this.results
      ..status = status ?? this.status;
  }
}

AddressInfoPlusCode $AddressInfoPlusCodeFromJson(Map<String, dynamic> json) {
  final AddressInfoPlusCode addressInfoPlusCode = AddressInfoPlusCode();
  final String? compoundCode = jsonConvert.convert<String>(json['compound_code']);
  if (compoundCode != null) {
    addressInfoPlusCode.compoundCode = compoundCode;
  }
  final String? globalCode = jsonConvert.convert<String>(json['global_code']);
  if (globalCode != null) {
    addressInfoPlusCode.globalCode = globalCode;
  }
  return addressInfoPlusCode;
}

Map<String, dynamic> $AddressInfoPlusCodeToJson(AddressInfoPlusCode entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['compound_code'] = entity.compoundCode;
  data['global_code'] = entity.globalCode;
  return data;
}

extension AddressInfoPlusCodeExtension on AddressInfoPlusCode {
  AddressInfoPlusCode copyWith({
    String? compoundCode,
    String? globalCode,
  }) {
    return AddressInfoPlusCode()
      ..compoundCode = compoundCode ?? this.compoundCode
      ..globalCode = globalCode ?? this.globalCode;
  }
}

AddressInfoResults $AddressInfoResultsFromJson(Map<String, dynamic> json) {
  final AddressInfoResults addressInfoResults = AddressInfoResults();
  final List<AddressInfoResultsAddressComponents>? addressComponents = (json['address_components'] as List<dynamic>?)
      ?.map(
          (e) => jsonConvert.convert<AddressInfoResultsAddressComponents>(e) as AddressInfoResultsAddressComponents)
      .toList();
  if (addressComponents != null) {
    addressInfoResults.addressComponents = addressComponents;
  }
  final String? formattedAddress = jsonConvert.convert<String>(json['formatted_address']);
  if (formattedAddress != null) {
    addressInfoResults.formattedAddress = formattedAddress;
  }
  final AddressInfoResultsGeometry? geometry = jsonConvert.convert<AddressInfoResultsGeometry>(json['geometry']);
  if (geometry != null) {
    addressInfoResults.geometry = geometry;
  }
  final List<AddressInfoResultsNavigationPoints>? navigationPoints = (json['navigation_points'] as List<dynamic>?)
      ?.map(
          (e) => jsonConvert.convert<AddressInfoResultsNavigationPoints>(e) as AddressInfoResultsNavigationPoints)
      .toList();
  if (navigationPoints != null) {
    addressInfoResults.navigationPoints = navigationPoints;
  }
  final String? placeId = jsonConvert.convert<String>(json['place_id']);
  if (placeId != null) {
    addressInfoResults.placeId = placeId;
  }
  final AddressInfoResultsPlusCode? plusCode = jsonConvert.convert<AddressInfoResultsPlusCode>(json['plus_code']);
  if (plusCode != null) {
    addressInfoResults.plusCode = plusCode;
  }
  final List<String>? types = (json['types'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<String>(e) as String).toList();
  if (types != null) {
    addressInfoResults.types = types;
  }
  return addressInfoResults;
}

Map<String, dynamic> $AddressInfoResultsToJson(AddressInfoResults entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['address_components'] = entity.addressComponents.map((v) => v.toJson()).toList();
  data['formatted_address'] = entity.formattedAddress;
  data['geometry'] = entity.geometry.toJson();
  data['navigation_points'] = entity.navigationPoints.map((v) => v.toJson()).toList();
  data['place_id'] = entity.placeId;
  data['plus_code'] = entity.plusCode.toJson();
  data['types'] = entity.types;
  return data;
}

extension AddressInfoResultsExtension on AddressInfoResults {
  AddressInfoResults copyWith({
    List<AddressInfoResultsAddressComponents>? addressComponents,
    String? formattedAddress,
    AddressInfoResultsGeometry? geometry,
    List<AddressInfoResultsNavigationPoints>? navigationPoints,
    String? placeId,
    AddressInfoResultsPlusCode? plusCode,
    List<String>? types,
  }) {
    return AddressInfoResults()
      ..addressComponents = addressComponents ?? this.addressComponents
      ..formattedAddress = formattedAddress ?? this.formattedAddress
      ..geometry = geometry ?? this.geometry
      ..navigationPoints = navigationPoints ?? this.navigationPoints
      ..placeId = placeId ?? this.placeId
      ..plusCode = plusCode ?? this.plusCode
      ..types = types ?? this.types;
  }
}

AddressInfoResultsAddressComponents $AddressInfoResultsAddressComponentsFromJson(Map<String, dynamic> json) {
  final AddressInfoResultsAddressComponents addressInfoResultsAddressComponents = AddressInfoResultsAddressComponents();
  final String? longName = jsonConvert.convert<String>(json['long_name']);
  if (longName != null) {
    addressInfoResultsAddressComponents.longName = longName;
  }
  final String? shortName = jsonConvert.convert<String>(json['short_name']);
  if (shortName != null) {
    addressInfoResultsAddressComponents.shortName = shortName;
  }
  final List<String>? types = (json['types'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<String>(e) as String).toList();
  if (types != null) {
    addressInfoResultsAddressComponents.types = types;
  }
  return addressInfoResultsAddressComponents;
}

Map<String, dynamic> $AddressInfoResultsAddressComponentsToJson(AddressInfoResultsAddressComponents entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['long_name'] = entity.longName;
  data['short_name'] = entity.shortName;
  data['types'] = entity.types;
  return data;
}

extension AddressInfoResultsAddressComponentsExtension on AddressInfoResultsAddressComponents {
  AddressInfoResultsAddressComponents copyWith({
    String? longName,
    String? shortName,
    List<String>? types,
  }) {
    return AddressInfoResultsAddressComponents()
      ..longName = longName ?? this.longName
      ..shortName = shortName ?? this.shortName
      ..types = types ?? this.types;
  }
}

AddressInfoResultsGeometry $AddressInfoResultsGeometryFromJson(Map<String, dynamic> json) {
  final AddressInfoResultsGeometry addressInfoResultsGeometry = AddressInfoResultsGeometry();
  final AddressInfoResultsGeometryLocation? location = jsonConvert.convert<AddressInfoResultsGeometryLocation>(
      json['location']);
  if (location != null) {
    addressInfoResultsGeometry.location = location;
  }
  final String? locationType = jsonConvert.convert<String>(json['location_type']);
  if (locationType != null) {
    addressInfoResultsGeometry.locationType = locationType;
  }
  final AddressInfoResultsGeometryViewport? viewport = jsonConvert.convert<AddressInfoResultsGeometryViewport>(
      json['viewport']);
  if (viewport != null) {
    addressInfoResultsGeometry.viewport = viewport;
  }
  return addressInfoResultsGeometry;
}

Map<String, dynamic> $AddressInfoResultsGeometryToJson(AddressInfoResultsGeometry entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['location'] = entity.location.toJson();
  data['location_type'] = entity.locationType;
  data['viewport'] = entity.viewport.toJson();
  return data;
}

extension AddressInfoResultsGeometryExtension on AddressInfoResultsGeometry {
  AddressInfoResultsGeometry copyWith({
    AddressInfoResultsGeometryLocation? location,
    String? locationType,
    AddressInfoResultsGeometryViewport? viewport,
  }) {
    return AddressInfoResultsGeometry()
      ..location = location ?? this.location
      ..locationType = locationType ?? this.locationType
      ..viewport = viewport ?? this.viewport;
  }
}

AddressInfoResultsGeometryLocation $AddressInfoResultsGeometryLocationFromJson(Map<String, dynamic> json) {
  final AddressInfoResultsGeometryLocation addressInfoResultsGeometryLocation = AddressInfoResultsGeometryLocation();
  final double? lat = jsonConvert.convert<double>(json['lat']);
  if (lat != null) {
    addressInfoResultsGeometryLocation.lat = lat;
  }
  final double? lng = jsonConvert.convert<double>(json['lng']);
  if (lng != null) {
    addressInfoResultsGeometryLocation.lng = lng;
  }
  return addressInfoResultsGeometryLocation;
}

Map<String, dynamic> $AddressInfoResultsGeometryLocationToJson(AddressInfoResultsGeometryLocation entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['lat'] = entity.lat;
  data['lng'] = entity.lng;
  return data;
}

extension AddressInfoResultsGeometryLocationExtension on AddressInfoResultsGeometryLocation {
  AddressInfoResultsGeometryLocation copyWith({
    double? lat,
    double? lng,
  }) {
    return AddressInfoResultsGeometryLocation()
      ..lat = lat ?? this.lat
      ..lng = lng ?? this.lng;
  }
}

AddressInfoResultsGeometryViewport $AddressInfoResultsGeometryViewportFromJson(Map<String, dynamic> json) {
  final AddressInfoResultsGeometryViewport addressInfoResultsGeometryViewport = AddressInfoResultsGeometryViewport();
  final AddressInfoResultsGeometryViewportNortheast? northeast = jsonConvert.convert<
      AddressInfoResultsGeometryViewportNortheast>(json['northeast']);
  if (northeast != null) {
    addressInfoResultsGeometryViewport.northeast = northeast;
  }
  final AddressInfoResultsGeometryViewportSouthwest? southwest = jsonConvert.convert<
      AddressInfoResultsGeometryViewportSouthwest>(json['southwest']);
  if (southwest != null) {
    addressInfoResultsGeometryViewport.southwest = southwest;
  }
  return addressInfoResultsGeometryViewport;
}

Map<String, dynamic> $AddressInfoResultsGeometryViewportToJson(AddressInfoResultsGeometryViewport entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['northeast'] = entity.northeast.toJson();
  data['southwest'] = entity.southwest.toJson();
  return data;
}

extension AddressInfoResultsGeometryViewportExtension on AddressInfoResultsGeometryViewport {
  AddressInfoResultsGeometryViewport copyWith({
    AddressInfoResultsGeometryViewportNortheast? northeast,
    AddressInfoResultsGeometryViewportSouthwest? southwest,
  }) {
    return AddressInfoResultsGeometryViewport()
      ..northeast = northeast ?? this.northeast
      ..southwest = southwest ?? this.southwest;
  }
}

AddressInfoResultsGeometryViewportNortheast $AddressInfoResultsGeometryViewportNortheastFromJson(
    Map<String, dynamic> json) {
  final AddressInfoResultsGeometryViewportNortheast addressInfoResultsGeometryViewportNortheast = AddressInfoResultsGeometryViewportNortheast();
  final double? lat = jsonConvert.convert<double>(json['lat']);
  if (lat != null) {
    addressInfoResultsGeometryViewportNortheast.lat = lat;
  }
  final double? lng = jsonConvert.convert<double>(json['lng']);
  if (lng != null) {
    addressInfoResultsGeometryViewportNortheast.lng = lng;
  }
  return addressInfoResultsGeometryViewportNortheast;
}

Map<String, dynamic> $AddressInfoResultsGeometryViewportNortheastToJson(
    AddressInfoResultsGeometryViewportNortheast entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['lat'] = entity.lat;
  data['lng'] = entity.lng;
  return data;
}

extension AddressInfoResultsGeometryViewportNortheastExtension on AddressInfoResultsGeometryViewportNortheast {
  AddressInfoResultsGeometryViewportNortheast copyWith({
    double? lat,
    double? lng,
  }) {
    return AddressInfoResultsGeometryViewportNortheast()
      ..lat = lat ?? this.lat
      ..lng = lng ?? this.lng;
  }
}

AddressInfoResultsGeometryViewportSouthwest $AddressInfoResultsGeometryViewportSouthwestFromJson(
    Map<String, dynamic> json) {
  final AddressInfoResultsGeometryViewportSouthwest addressInfoResultsGeometryViewportSouthwest = AddressInfoResultsGeometryViewportSouthwest();
  final double? lat = jsonConvert.convert<double>(json['lat']);
  if (lat != null) {
    addressInfoResultsGeometryViewportSouthwest.lat = lat;
  }
  final double? lng = jsonConvert.convert<double>(json['lng']);
  if (lng != null) {
    addressInfoResultsGeometryViewportSouthwest.lng = lng;
  }
  return addressInfoResultsGeometryViewportSouthwest;
}

Map<String, dynamic> $AddressInfoResultsGeometryViewportSouthwestToJson(
    AddressInfoResultsGeometryViewportSouthwest entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['lat'] = entity.lat;
  data['lng'] = entity.lng;
  return data;
}

extension AddressInfoResultsGeometryViewportSouthwestExtension on AddressInfoResultsGeometryViewportSouthwest {
  AddressInfoResultsGeometryViewportSouthwest copyWith({
    double? lat,
    double? lng,
  }) {
    return AddressInfoResultsGeometryViewportSouthwest()
      ..lat = lat ?? this.lat
      ..lng = lng ?? this.lng;
  }
}

AddressInfoResultsNavigationPoints $AddressInfoResultsNavigationPointsFromJson(Map<String, dynamic> json) {
  final AddressInfoResultsNavigationPoints addressInfoResultsNavigationPoints = AddressInfoResultsNavigationPoints();
  final AddressInfoResultsNavigationPointsLocation? location = jsonConvert.convert<
      AddressInfoResultsNavigationPointsLocation>(json['location']);
  if (location != null) {
    addressInfoResultsNavigationPoints.location = location;
  }
  return addressInfoResultsNavigationPoints;
}

Map<String, dynamic> $AddressInfoResultsNavigationPointsToJson(AddressInfoResultsNavigationPoints entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['location'] = entity.location.toJson();
  return data;
}

extension AddressInfoResultsNavigationPointsExtension on AddressInfoResultsNavigationPoints {
  AddressInfoResultsNavigationPoints copyWith({
    AddressInfoResultsNavigationPointsLocation? location,
  }) {
    return AddressInfoResultsNavigationPoints()
      ..location = location ?? this.location;
  }
}

AddressInfoResultsNavigationPointsLocation $AddressInfoResultsNavigationPointsLocationFromJson(
    Map<String, dynamic> json) {
  final AddressInfoResultsNavigationPointsLocation addressInfoResultsNavigationPointsLocation = AddressInfoResultsNavigationPointsLocation();
  final double? latitude = jsonConvert.convert<double>(json['latitude']);
  if (latitude != null) {
    addressInfoResultsNavigationPointsLocation.latitude = latitude;
  }
  final double? longitude = jsonConvert.convert<double>(json['longitude']);
  if (longitude != null) {
    addressInfoResultsNavigationPointsLocation.longitude = longitude;
  }
  return addressInfoResultsNavigationPointsLocation;
}

Map<String, dynamic> $AddressInfoResultsNavigationPointsLocationToJson(
    AddressInfoResultsNavigationPointsLocation entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['latitude'] = entity.latitude;
  data['longitude'] = entity.longitude;
  return data;
}

extension AddressInfoResultsNavigationPointsLocationExtension on AddressInfoResultsNavigationPointsLocation {
  AddressInfoResultsNavigationPointsLocation copyWith({
    double? latitude,
    double? longitude,
  }) {
    return AddressInfoResultsNavigationPointsLocation()
      ..latitude = latitude ?? this.latitude
      ..longitude = longitude ?? this.longitude;
  }
}

AddressInfoResultsPlusCode $AddressInfoResultsPlusCodeFromJson(Map<String, dynamic> json) {
  final AddressInfoResultsPlusCode addressInfoResultsPlusCode = AddressInfoResultsPlusCode();
  final String? compoundCode = jsonConvert.convert<String>(json['compound_code']);
  if (compoundCode != null) {
    addressInfoResultsPlusCode.compoundCode = compoundCode;
  }
  final String? globalCode = jsonConvert.convert<String>(json['global_code']);
  if (globalCode != null) {
    addressInfoResultsPlusCode.globalCode = globalCode;
  }
  return addressInfoResultsPlusCode;
}

Map<String, dynamic> $AddressInfoResultsPlusCodeToJson(AddressInfoResultsPlusCode entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['compound_code'] = entity.compoundCode;
  data['global_code'] = entity.globalCode;
  return data;
}

extension AddressInfoResultsPlusCodeExtension on AddressInfoResultsPlusCode {
  AddressInfoResultsPlusCode copyWith({
    String? compoundCode,
    String? globalCode,
  }) {
    return AddressInfoResultsPlusCode()
      ..compoundCode = compoundCode ?? this.compoundCode
      ..globalCode = globalCode ?? this.globalCode;
  }
}